'Brook's Functions
' $HeadURL
' $Author
' $Revision
' $Date

Module BrookFunctions
    Sub RegisterFunctions(ByRef funcList As FunctionList)
        funcList.RegisterFunction("switch", AddressOf switch)
    End Sub

    'Switch statment, equivilent to select case
    Function switch(ByVal args As ArgList, ByRef script As Script) As Boolean
        Dim argLength As Integer = args.Count

        Dim tests As Integer = (argLength / 2) - 1

        Dim teste As Argument = args.Item(0)

        For i As Integer = 1 To argLength - 2 Step 2
            Dim equal As Argument = args.Item(i)
            Dim go As Argument = args.Item(i + 1)
            If teste.Data = equal.Data Then
                script.SetInstructionPointer(go.Data)
                Return True
            End If
        Next

        script.SetInstructionPointer(args.Item(argLength - 1).Data)
        Return True
    End Function
End Module
